<template>
  <a-card :bordered='false'>
    <search :config='searchConfig' @search='search' @getHeight='getHeight' />
    <div class='page_table'>
      <vxe-grid
        ref='xGrid'
        :border='true'
        :resizable='true'
        :showOverflow='true'
        size='mini'
        :loading='loading'
        :height='pageHeight-seachHeight-94'
        :align='left'
        :columns='columns'
        :data='dataSource'
        :toolbar-config="tableToolbar"
       :checkbox-config="checkboxConfig"
        v-bind='vexConfig'
        @checkbox-change='selectChangeEvent'
        @checkbox-all="selectChangeEvent"
      >
        <template #toolbar_buttons>
          <div class='table-operator'>
            <a-button @click="handleAdd" type="primary">新增</a-button>
            <a-button tabindex="primary" @click="batchDel">删除</a-button>
            <!-- <a-button type="primary">导入</a-button> -->
            <a-button type="primary" @click="downExportXls('covist_report')">导出</a-button>
<!--            <a-button type="primary">日志</a-button>-->
          </div>
        </template>


        <template  #action='{ row,rowIndex }'>
<!--          <a v-has="'getGoodsAdress:update'" @click='handleEdit(row)'>编辑</a>-->
<!--          <a-divider type='vertical' />-->
          <a href='javascript:' @click='handleBusiness("协访计划",row)'>日志</a>
        </template>
        <template #receivingAddressCode='{ row,rowIndex }'>
          <a @click="handleDetail(row)">{{ row.receivingAddressCode }}</a>
        </template>
        <template #update='{ row }'>
          <a-switch :checked='row.status' size='small' @change='handleStatus(row,$event)' />
        </template>
        <template #update='{ row }'>
          <a-switch :checked='row.status' size='small' @change='handleStatus(row,$event)' />
        </template>
        <template #pager>
          <vxe-pager
            :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
            :currentPage.sync='ipagination.current'
            :page-size.sync='ipagination.pageSize'
            :total='ipagination.total'
            :pageSizes='ipagination.pageSizeOptions'
            @page-change='handlePageChange'>
          </vxe-pager>
        </template>
      </vxe-grid>
    </div>
    <!-- 弹出层 -->
    <PlanMakingModal ref="modalForm" @ok="modalFormOk"></PlanMakingModal>
    <business-log ref="businessLog"></business-log>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import {PageListMixin} from '@/mixins/PageListMixin'
  import {getAction} from '@/api/manage'
  import ARow from 'ant-design-vue/es/grid/Row'
  import ARangePicker from 'ant-design-vue/es/date-picker/RangePicker'
  import PlanMakingModal from './modules/PlanMakingModal'
  export default {
    name: "SignConfigList",
    mixins: [PageListMixin],
    components: {
      ARangePicker,
      PlanMakingModal,
      ARow
    },
    data() {
      return {
        description: '协访计划定制页面',
        // 表头
        showImg:false,
        imgSrc:"",
        searchConfig: [
          {
            type: 'input',
            name: 'visitUserRealName',
            placeholder: '协访人员'
          },
          {
            type: 'input',
            name: 'visitPosName',
            placeholder: '协访人员职位'
          },
          {
            type:'date-range',
            name:'date',
            range:['visitDateStart','visitDateEnd'],
            placeholder:['协访开始时间','协访结束时间']
          },
          {
            type: 'input',
            name: 'visitAssistUserRealName',
            placeholder: '被协访人员'
          },
        ],
        columns: [
          {
            minWidth:60,
            type:'checkbox',
          },
          {
            title: '被协访人员姓名',
            minWidth:120,
            field: 'visitAssistUserRealName'
          },
          {
            title: '协访日期',
            minWidth:100,
            field: 'visitDateStart'
          },
          {
            title: '协访人员',
            minWidth:100,
            field: 'visitUserRealName'
          },
          {
            title: '协访人员职位名称',
            minWidth:120,
            field: 'visitPosName'
          },
          {
            title: '协访门店',
            minWidth:120,
            field: 'clientName'
          },
          {
            title: '协访人员所属组织',
            minWidth:120,
            field: 'visitOrgName'
          },
          {
            title: '被协访人员职位名称',
            minWidth:140,
            field: 'visitAssistPosName'
          },
          {
            title: '被协访人员所属组织',
            minWidth:140,
            field: 'visitAssistOrgName'
          },
          {
            title: '创建人',
            minWidth:80,
            field: 'createName'
          },
          {
            title: '创建时间',
            minWidth:80,
            field: 'createTime'
          },
          {
            title: '更新人',
            minWidth:100,
            field: 'updateName'
          },
          {
            title: '更新时间',
            minWidth:80,
            field: 'updateTime'
          },
          {
            title: '操作',
            field: 'action',
            minWidth: 80,
            slots: { default: 'action' }
          }
        ],
        isorter: {
          visitType: '2',
          permflag: 'plan_making_page_impl'
        },
        url: {
          list: window._CONFIG['domianSfaURL'] + "/visit/sfaVisitLineController/findPageList",
          delete: window._CONFIG['domianSfaURL'] + "/signConfig/deleteById",
          deleteBatch: window._CONFIG['domianSfaURL'] + "/visit/sfaVisitLineController/deleteBatchVisit",
          startOrStopUrl: window._CONFIG['domianSfaURL'] + "/signConfig/status/startOrStop"
        }
      }
    },

    methods: {
      startorstop: function (status) {

        if (!this.url.startOrStopUrl) {
          this.$message.error("请设置url启用停用!")
          return;
        }
        if (this.selectedRowKeys.length <= 0) {
          this.$message.warning('请选择一条记录！');
          return;
        }
        let param = {...this.queryParam}
        param['status'] = status
        if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
          param['selections'] = this.selectedRowKeys.join(",")
        }else {
          param['selections'] = this.selectedRowKeys[0]
        }
        // if (this.selectedRowKeys.length != 1) {
        //   this.$message.warning('请选择一条记录！');
        //   return;
        // } else {
        // var id = this.selectedRowKeys;
        var that = this;
        that.loading = true;
        getAction(this.url.startOrStopUrl, param ).then((res) => {
          if (res.success) {
            that.$message.success(res.message);
            that.loadData();
          } else {
            that.$message.warning(res.message);
          }
          that.loading = false;
        });
      }
    }

  }
</script>

<style scoped>
  @import '~@assets/less/common.less';
</style>